package org.cocopapaya.anttsp.domain;

import java.util.ArrayList;
import java.util.Collection;

import edu.uci.ics.jung.graph.Graph;

public class City {
	
	private static long instances =0;
	private long id;

	public Collection<Object> inhabitants = new ArrayList<Object>();

	private Graph<City, Path> graph;

	public City(Graph<City, Path> graph) {
		super();
		this.id = instances++;
		this.graph = graph;
	}

	public void enter(Object o) {
		this.inhabitants.add(o);
	}

	public void leave(Object o) {
		this.inhabitants.remove(o);
	}

	public String toString() {
		return this.id+""+this.inhabitants.toString();
	}

	public City getOpposite(Path p) {
		return this.graph.getOpposite(this, p);

	}

	public Collection<Path> getExits() {
		return this.graph.getOutEdges(this);

	}

	public void clear() {
		this.inhabitants.clear();
		
	}

	public int countInhabitants() {
		// TODO Auto-generated method stub
		return this.inhabitants.size();
	}

	public boolean contains(Object arg0) {
		// TODO Auto-generated method stub
		return this.inhabitants.contains(arg0);
	}

}
